home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / comm / irc / epic4-mos.lha / share / epic / script / netsplit < prev    next >
Text File  |  2002-09-18  |  4KB  |  161 lines

  1. # NETSPLIT 7 - This script does it's best to suppress the excessive 
  2. # joins and signoffs due ONLY to netsplits.  It should pass regular
  3. # signoffs.   Need at least ircII2.2pre6
  4. # Version II  handles multiple channels.         (mycroft)
  5. # Version III ignores bogus signoff messages
  6. # Version IV  handles multiple splits.
  7. # Version V   handles multiple splits and ignores bogus signoff messages. also
  8. #             adds timestamps to split/join messages
  9. # Version VI  For ircII2.2pre8 and beyond. Uses encode() and decode() 
  10. # Version VII Fixed a problem with encode() and decode() and case
  11. #             sensitive channel names, + adding lformat()
  12. #
  13. # This one by Daemon
  14. # CONVERTED for ircII2.2pre8
  15. # Version V by poxaV (cgw@unt.edu), from Daemon's code
  16. # modified last 7-03-93
  17.  
  18. #shows the current time in HH:MM:SS format
  19. ^alias currtime @ function_return = strftime(%T)
  20.  
  21. # This function tests for bogus splits.
  22. ^alias isbogus {
  23.     ^if ([$3]) { @ function_return = 1 }
  24.     ^if (rmatch(.$1. $isbogus.pats *..*)) { @ function_return = 1 }
  25.     ^if (rmatch(.$2. $isbogus.pats *..*)) { @ function_return = 1 }
  26. }
  27.  
  28. # Add patterns.. like /boguspat *bonk* *thud* *haha*
  29. # that will NOT be treated as server names..
  30. ^alias boguspat ^assign isbogus.pats $isbogus.pats $0-;echo $0- added
  31.  
  32. # Next two are pretty obvious
  33. ^alias boguslist echo Pats: $isbogus.pats
  34. ^alias bogusclear ^assign -isbogus.pats;echo Bogus list clean
  35.  
  36. # If first word in Signoff contains a period then assume servername
  37. # and thus a a split.  Stash in assoc array.
  38. ^ON ^CHANNEL_SIGNOFF "% % %.% %.%" {
  39.     if (isbogus($1-)) 
  40.         { echo *** Signoff: $1 \($2-\) }
  41.         { ^netbroke $encode($tolower($0)) $encode($1) $encode($2).$encode($3) $2 $3 }
  42. }
  43.  
  44. # Stuff array. Tell us what server broke and set split flag.
  45. ^alias netbroke {
  46.   @ signcross[$2][$0][$1] = 1
  47.   @ signoffs[$0][$1] = [$2]
  48.   @ splittime[$2] = time()
  49.   ^if ( !isbroke[$2] )
  50.   {
  51.     xecho -level OPNOTES *** Netsplit at $currtime() \($3-\)
  52.     @ isbroke[$2] = 1
  53.     @ splitname[$2] = [$3-]
  54.   }
  55. }
  56.  
  57. # When a person joins a channel.. Check them against the array.
  58. # If they are in array, then remove silently.  Otherwards echo normally
  59. ^ON ^JOIN * {
  60.   ^netjoined $encode($tolower($1)) $encode($0) $1 $0 $USERHOST()
  61. }
  62.  
  63. # Unset the split flag
  64. ^alias netjoined {
  65.   if ( signoffs[$0][$1] )
  66.   {
  67.     ^if ( isbroke[$signoffs[$0][$1]] )
  68.     {
  69.       xecho -level OPNOTES *** Netjoined at $currtime() \($splitname[$signoffs[$0][$1]]\)
  70.     }
  71.     ^assign -isbroke[$signoffs[$0][$1]]
  72.     ^assign -signcross[$signoffs[$0][$1]][$0][$1]
  73.     ^assign -signoffs[$0][$1]
  74.   }
  75.   {
  76.     echo *** $3 \($4-\) has joined channel $2
  77.   }
  78. }
  79.  
  80. # Clear the array every 10 minutes to prevent excess garbage
  81. ^on #^timer 70 * netclean
  82. ^alias netclean {
  83.     foreach splittime ii
  84.     {
  85.         foreach splittime.$ii jj
  86.         {
  87.             if ( time() - splittime[$ii][$jj] > 300 )
  88.             {
  89.                 foreach signcross.$(ii).$jj xx
  90.                 {
  91.                     foreach signcross.$(ii).$(jj).$xx yy
  92.                     {
  93.                         @ signcross[$ii][$jj][$xx][$yy] = signoffs[$xx][$yy] = []
  94.                     }
  95.                 }
  96.                 @ xx = yy = isbroke[$ii][$jj] = []
  97.                 @ splitname[$ii][$jj] = splittime[$ii][$jj] = []
  98.             }
  99.         }
  100.     }
  101. }
  102.  
  103. ^alias netpurge {
  104.   purge isbroke
  105.   purge splitname
  106.   purge splittime
  107.   purge signcross
  108.   purge signoffs
  109. }
  110.  
  111. # If you want to suppress mode changes by servers.. (usually after a split)
  112. # then uncomment next line
  113. # ^on ^mode "%.%" #
  114.  
  115. # If you want to look an array.. Type /show <arrayname>
  116. # Lists keys and contents
  117. ^alias showsplit {
  118.   if ( [$($0)] )
  119.   {
  120.     echo $0 $($0)
  121.   }
  122.   foreach $0 ii
  123.   {
  124.     showsplit $0.$ii
  125.   }
  126.   ^assign -ii
  127. }
  128.  
  129. ^alias purge {
  130.   foreach $0 ii
  131.   {
  132.     purge $0.$ii
  133.   }
  134.   ^assign -ii
  135.   ^assign -$0
  136. }
  137.  
  138. ^alias wholeft {
  139.   foreach signoffs ii
  140.   {
  141.     foreach signoffs.$ii jj
  142.     {
  143.       echo $lformat(15 $decode($ii)) $lformat(10 $decode($jj)) $splitname[$signoffs[$ii][$jj]]
  144.     }
  145.   }
  146.   ^assign -ii
  147.   ^assign -jj
  148. }
  149.  
  150. # format and lformat differ from $[-num]var and $[num]var in that
  151. # They don't chop off the string if it is too long.
  152.  
  153. alias lformat {
  154.     @ IRCII.word = [$1-]
  155.     if (@IRCII.word < [$0]) 
  156.         { @ function_return = [$([$0]IRCII.word)] } 
  157.         { @ function_return = [$IRCII.word] } 
  158. }
  159.  
  160. # Many people contributed to this script.
  161.